<?php

include '../../init.php';

// 查询个人信息
$uid = @$_GET['uid'];
$sql = "SELECT l.isStop as isStop,u.alias as alias, u.truename as truename, u.avatarid as avatarid, u.gender as gender,";
$sql .="u.birthyear as birthyear, u.phone as phone, u.qid as qid, u.answer as answer,u.address as address ";
$sql .="FROM `userinfo_tb` as u, `login_tb` as l WHERE u.uid=".$uid.' AND u.uid=l.uid LIMIT 1;';
$arr = array();
if (!my_mysql_query($sql, $arr)){
	show_msg(1, '获取个人信息失败', 3, '../../index.php');
	exit();
}
$arr = $arr[0];
?>
<!DOCTYPE html>

<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>个人信息</title>
	<meta name="keywords" content="">

	<link rel="stylesheet" type="text/css" href="./css/style_3_common.css">
	<link rel="stylesheet" type="text/css" href="./css/style_3_home_space.css">
	<link rel="stylesheet" id="css_widthauto" type="text/css" href="./css/style_3_widthauto.css">
	<link rel="stylesheet" type="text/css" id="gfan_css" href="./css/gfan_bbs.css">

	<style type="text/css">
	.ct2_a .appl {
		margin-left: -150px;
	}
	.appl {
		float: left;
		overflow: hidden;
		margin-bottom: 10px;
		padding: 6px 10px;
		width: 117px;
	}
    .main-div{
        width:960px;
        margin:25px auto;
        background-color:#F7F7F7;
    }
    body{
        background-color:#F9F9F9;
    }
	</style>
</head>

<body id="nv_home" class="pg_space">
	<div class="main-div">
		<div id="pt" class="bm cl">
			<div class="z">
				<a href="../../index.php" title="首页">首页</a> <em>›</em>个人资料
				<?php
				// 用户已经被禁言,管理员能看到
				// 管理员有禁言权限,并且管理员不能对自己禁言
				if (@$_SESSION['isAdmin'] && $arr['isStop']) {
					echo '该用户已被禁言';
				} elseif (@$_SESSION['isAdmin'] && $_SESSION['uid'] != $uid){
				?>
					<form action=" update.php" method="POST" style="display:inline-block;">
						<input type="hidden" name="uid" value="<?php echo $uid; ?>">
						<button type="submit" name="method" value="shutUp">禁言</button>
					</form>
					<?php
					echo '<a href="./update.php?action=shutUp">';
				}
				?>
			</div>
		</div>
		<div id="ct" class="ct2_a cl">
			<div class="mn">
				<div class="bm bw0">
					<h1 class="mt">个人资料
					</h1>
					<ul class="tb cl">
						<li class="a"><a href="#">基本资料</a></li>
					</ul>
					<form action="update.php" method="post" autocomplete="off">
						<input type="hidden" name="method" value="update_base_info">
						<table cellspacing="0" cellpadding="0" class="tfm" id="profilelist">
							<tbody>
								<tr>
									<th>用户名</th>
									<td>
										<input type="text" name="alias" class="px" value="<?php echo $arr['alias']?>">
									</td>
									<td>&nbsp;</td>
								</tr>
								<tr id="tr_gender">
									<th id="th_gender">性别</th>
									<td id="td_gender">
										<select name="gender" id="gender" class="ps">
											<option value="0" <?php echo @$arr['gender']==2? 'selected="selected"': ''; ?>>保密</option>
											<option value="1" <?php echo @$arr['gender']==1? 'selected="selected"': ''; ?>>男</option>
											<option value="2" <?php echo @$arr['gender']==0? 'selected="selected"': ''; ?>>女</option>
										</select>
										<div class="rq mtn" id="showerror_gender"></div><p class="d"></p></td>
										<td class="p">
										</td>
									</tr>
									<tr id="tr_birthday">
										<th id="th_birthday">生日</th>
										<td id="td_birthday">
											<input type="date" name="birthyear" id="birthyear" class="px" value=
											<?php
											echo '"'.date('Y-m-d', $arr['birthyear']).'"';
											?>>
											<div class="rq mtn" id="showerror_birthday"></div>
											<p class="d"></p>
										</td>
										<td class="p">
										</td>
									</tr>
									<tr id="tr_realname">
										<th id="th_realname">真实姓名</th>
										<td id="td_realname">
											<input type="text" name="truename" id="realname" class="px" value="<?php echo @$arr['truename']?>">
											<div class="rq mtn" id="showerror_realname"></div>
											<p class="d"></p>
										</td>
										<td class="p">
										</td>
									</tr>
									<tr id="tr_residecity">
										<th id="th_residecity">居住地</th>
										<td id="td_residecity">
											<p id="residedistrictbox">
												<input type="text" name="address" class="px" value="<?php echo @$arr['address']?>" >
											</p>
											<div class="rq mtn" id="showerror_residecity"></div>
											<p class="d"></p>
										</td>
										<td class="p">
										</td>
									</tr>
									<tr>
										<th>&nbsp;</th>
										<td colspan="2">

										<?php
										if ($uid == @$_SESSION['uid']) {
										?>
											<input type="hidden" name="profilesubmit" value="true">
											<button type="submit" name="profilesubmitbtn" id="profilesubmitbtn" value="true" class="pn pnc">
												<strong>保存</strong>
											</button>
											<span id="submit_result" class="rq"></span>
										<?php
										}
										?>
										</td>
									</tr>
								</tbody>
							</table>
						</form>
					</div>
				</div>
				<div class="appl"><div class="tbn">
					<h2 class="mt bbda">设置</h2>
					<ul>
						<li class="a"><a href="#">个人资料</a></li>
					<?php
					// 如果不是当前用户,就不能查看该用户的其它信息
					if ($uid == @$_SESSION['uid']){
						echo '<li><a href="avatar.php">修改头像</a></li>';
						echo '<li><a href="score.php">积分</a></li>';
						echo '<li><a href="safe.php">密码安全</a></li>';
					}
					?>
					</ul>
				</div>
			</div>
		</div>
	</div>
</body>
</html>
